<template>
  <div class="el-panel">
    <div class="el-panel-header" v-if="title || $slots.header " :class="{'with-border':widthBorder}">
      <slot name="header">
        <h3 class="el-panel-title" v-text="title" v-if="title" ></h3>
        <slot name="collapse">
          <i @click="show" v-if="collapse" class="el-collapse-item__arrow el-icon-arrow-right " :class="{'is-active':isShow}"></i>
        </slot>
        <slot name="back">
          <a href="javascript:;" v-if="back" type="danger" class="back el-icon-back"  round size="mini" @click="goBack">  返回 </a>
        </slot>
        <slot name="el-panel-btn">
          <div class="el-panel-btn"></div>
        </slot>
      </slot>
    </div>
    <el-collapse-transition>
      <div class="el-panel-body" v-show="isShow">
          <slot name="body" v-if="$slots.body">
            暂无内容显示
          </slot>
          <slot v-else>
          </slot>
      </div>
      <div class="el-panel-footer" v-text="footer" v-if="footer">
      </div>
    </el-collapse-transition>
  </div>
</template>

<script type="text/javascript">
  export default {
    name: 'elpanel',
    props: {
      widthBorder: {
        type: Boolean
      },
      title: {
        type: String
      },
      collapse: {
        type: Boolean,
        default: false
      },
      back: {
        type: Boolean,
        default: false
      },
      footer: {
        type: String
      },
    },
    data() {
      return {
        isShow: true
      }
    },
    methods: {
      goBack:function(){
        window.history.go(-1);
      },
      show() {
        this.isShow = !this.isShow;
      }
    },
  }
</script>

<style scoped>
  .el-panel {
    box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .12), 0 0 6px 0 rgba(0, 0, 0, .04);
    border: 1px solid #dcdfe6;
    position: relative;
    background: #ffffff;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
  }
  .is-active-body{
    height: 0px;
    overflow: hidden;
  }
  .el-collapse-item__arrow{
    cursor: pointer;
  }
  .el-panel .el-collapse-item__arrow {
    line-height: 1;
  }
  
  .el-panel .overlay.dark,
  .overlay-wrapper .overlay.dark {
    background: rgba(0, 0, 0, 0.5);
  }
  
  .el-panel-header:before,
  .el-panel-body:before,
  .el-panel-footer:before,
  .el-panel-header:after,
  .el-panel-body:after,
  .el-panel-footer:after {
    content: " ";
    display: table;
  }
  
  .el-panel-header:after,
  .el-panel-body:after,
  .el-panel-footer:after {
    clear: both;
  }
  
  .el-panel-header {
    color: #909399;
    background: #f5f7fa;
    border-bottom: 1px solid #e4e7ed;
    padding: 11px 15px;
    position: relative;
    font-size: 14px;
    line-height: 14px;
  }
  .back{
    float: right;
  }
  
  .el-panel-header.with-border {
    border-bottom: 1px solid #f4f4f4;
  }
  
  .collapsed-box .el-panel-header.with-border {
    border-bottom: none;
  }
  
  .el-panel-header>.fa,
  .el-panel-header>.glyphicon,
  .el-panel-header>.ion,
  .el-panel-header .el-panel-title {
    display: inline-block;
    font-size: 14px;
    margin: 0;
    line-height: 1;
  }
  
  .el-panel-header>.fa,
  .el-panel-header>.glyphicon,
  .el-panel-header>.ion {
    margin-right: 5px;
  }
  
  .el-panel-header>.el-panel-tools {
    position: absolute;
    right: 10px;
    top: 5px;
  }
  
  .el-panel-header>.el-panel-tools [data-toggle="tooltip"] {
    position: relative;
  }
  
  .el-panel-header>.el-panel-tools.pull-right .dropdown-menu {
    right: 0;
    left: auto;
  }
  
  .el-panel-header>.el-panel-tools .dropdown-menu>li>a {
    color: #444!important;
  }
  
  .el-panel-body {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 3px;
    border-bottom-left-radius: 3px;
    padding: 20px !important;
  }
  
  
  .el-panel-footer {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 3px;
    border-bottom-left-radius: 3px;
    border-top: 1px solid #f4f4f4;
    padding: 10px;
    background-color: #ffffff;
  }
  .is-active-body{
    padding: 0;
    height: 0px;
    overflow: hidden;
  }
  .el-panel-btn {
    float: right;
  }
</style>
